#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
	int n;
	cin >> n;
	set<int> s;
	int a2;
	while (cin >> n) {
		if (s.count(n))
			a2 = n;
		s.insert(n);
	}
	int mn = *min_element(s.begin(), s.end());
	int mx = *max_element(s.begin(), s.end());
	for (int i = mn; i <= mx; i++) {
		if (!s.count(i)) {
			cout << i << " ";
			break;
		}
	}
	cout << a2;
	return 0;
}
